import Vue from "vue";
import Router from "vue-router";
import Main from "pages/Main";
import home from "pages/home/home";

// 评估管理
import assessManage from "pages/assessManage/index";
import assessManageEdit from "pages/assessManage/edit";
import assessManageDetail from "pages/assessManage/detail";
import assessManageFollow from "pages/assessManage/follow";

// 采购管理
import buyManage from "pages/buyManage/index";
import buyContractDetail from "pages/buyManage/contractDetail";
import buyContractEdit from "pages/buyManage/contractEdit";
import PaymentOrder from "pages/buyManage/PaymentOrder";
import PaymentOrderEdit from "pages/buyManage/PaymentOrderEdit";
import CarStorge from "pages/buyManage/CarStorge";
import CarStorgeEdit from "pages/buyManage/CarStorgeEdit";
import PurchaseInvoice from "pages/buyManage/PurchaseInvoice";
import PurchaseInvoiceEdit from "pages/buyManage/PurchaseInvoiceEdit";
import RelateContract from "pages/buyManage/RelateContract";

// 库存管理
import inventoryManage from "pages/inventoryManage/index";
import inventoryManageDetail from "pages/inventoryManage/Detail";
import RepairOrder from "pages/inventoryManage/RepairOrder";
import YscShop from "pages/inventoryManage/YscShop";

// 销售线索
import salesLeads from "pages/salesLeads/index";
import salesLeadsDetails from "pages/salesLeads/detail";
import salesLeadsEdit from "pages/salesLeads/edit";
import salesLeadsAdd from "pages/salesLeads/add";
// 销售管理
import salesManage from "pages/salesManage/index";
import salesManageDetail from "pages/salesManage/Detail";
import salesManageSaleReceive from "pages/salesManage/SaleReceive";
import salesManageSaleInvoice from "pages/salesManage/SaleInvoice";
import salesManageSaleIssued from "pages/salesManage/SaleIssued";
import salesManageInsurance from "pages/salesManage/Insurance";
import salesManageDoTrust from "pages/salesManage/DoTrust";
import salesManageFinalService from "pages/salesManage/FinalService";
import SaleIssuedEdit from "pages/salesManage/SaleIssuedEdit";

// 客户管理
import customManage from "pages/customManage/index"
import customManageAdd from "pages/customManage/add"
import customManageDetail from "pages/customManage/detail"
import customManageFollowEdit from "pages/customManage/followEdit"
import customManageFollowAdd from "pages/customManage/followEdit"
import customManageFollowDetail from "pages/customManage/followDetail"

// 附属表
import attachedTable from "pages/attachedTable/index";
import attachedDetail from "pages/attachedTable/detail";
import attachedEdit from "pages/attachedTable/edit";

import fileMange from "pages/fileMange/index";


Vue.use(Router);

const router =  new Router({
  linkActiveClass: "cur",
  mode: "history",
  base:'ysc',
  routes: [
    {
      path: "/",
      //name: 'Main',
      component: Main,
      children: [
        {
          path: "",
          name: "Main",
          component: home,
          meta: {
            title: "二手车业务系统"
          }
        },
        {
          path: "/home",
          name: "home",
          component: home,
          meta: {
            title: "二手车业务系统"
          }
        }
      ]
    },
    {
      path: "/assessManageDetail",
      name: "assessManageDetail",
      component: assessManageDetail,
      meta: {
        title: "评估线索详情"
      }
    },
    {
      path: "/assessManage",
      name: "assessManage",
      component: assessManage,
      meta: {
        title: "评估管理",
        keepAlive:true
      }
    },
    {
      path: "/assessManageEdit",
      name: "assessManageEdit",
      component: assessManageEdit,
      meta: {
        title: "新增评估线索"
      }
    },
    {
      path: "/assessManageDetail",
      name: "assessManageDetail",
      component: assessManageDetail,
      meta: {
        title: "评估线索详情"
      }
    },
    {
      path: "/assessManageFollow",
      name: "assessManageFollow",
      component: assessManageFollow,
      meta: {
        title: "线索跟进"
      }
    },
    {
      path: "/buyManage",
      name: "buyManage",
      component: buyManage,
      meta: {
        title: "采购管理",
        keepAlive:true
      }
    },
    {
      path: "/buyContractDetail",
      name: "buyContractDetail",
      component: buyContractDetail,
      meta: {
        title: "采购合同详情"
      }
    },
    {
      path: "/buyContractEdit",
      name: "buyContractEdit",
      component: buyContractEdit,
      meta: {
        title: "采购合同编辑"
      }
    },
    {
      path: "/inventoryManage",
      name: "inventoryManage",
      component: inventoryManage,
      meta: {
        title: "库存管理",
        keepAlive:true
      }
    },
    {
      path: "/salesLeads",
      name: "salesLeads",
      component: salesLeads,
      meta: {
        title: "销售线索",
        keepAlive:true
      }
    },
    {
      path: "/salesLeadsDetails",
      name: "salesLeadsDetails",
      component: salesLeadsDetails,
      meta: {
        title: "销售线索详情"
      }
    },
    {
      path: "/salesLeadsEdit",
      name: "salesLeadsEdit",
      component: salesLeadsEdit,
      meta: {
        title: "销售线索详情编辑"
      }
    },
    {
      path: "/salesLeadsAdd",
      name: "salesLeadsAdd",
      component: salesLeadsAdd,
      meta: {
        title: "新增销售线索"
      }
    },
    {
      path: "/salesManage",
      name: "salesManage",
      component: salesManage,
      meta: {
        title: "销售合同",
        keepAlive:true

      }
    },
    {
      path: "/salesManageDetail",
      name: "salesManageDetail",
      component: salesManageDetail,
      meta: {
        title: "销售合同详情"
      }
    },
    {
      path: "/salesManageSaleReceive",
      name: "salesManageSaleReceive",
      component: salesManageSaleReceive,
      meta: {
        title: "整车收款单详情"
      }
    },
    {
      path: "/salesManageSaleInvoice",
      name: "salesManageSaleInvoice",
      component: salesManageSaleInvoice,
      meta: {
        title: "整车开票单详情"
      }
    },
    {
      path: "/salesManageSaleIssued",
      name: "salesManageSaleIssued",
      component: salesManageSaleIssued,
      meta: {
        title: "销售出库单详情"
      }
    },
      {
      path: "/SaleIssuedEdit",
      name: "SaleIssuedEdit",
      component: SaleIssuedEdit,
      meta: {
        title: "销售出库单编辑"
      }
    },

    {
      path: "/salesManageInsurance",
      name: "salesManageInsurance",
      component: salesManageInsurance,
      meta: {
        title: "保险登记单详情"
      }
    },
    {
      path: "/salesManageDoTrust",
      name: "salesManageDoTrust",
      component: salesManageDoTrust,
      meta: {
        title: "代办委托书详情"
      }
    },
    {
      path: "/salesManageFinalService",
      name: "salesManageFinalService",
      component: salesManageFinalService,
      meta: {
        title: "金融服务费收款详情"
      }
    },

    {
      path: "/attachedTable",
      name: "attachedTable",
      component: attachedTable,
      meta: {
        title: "附属表",
        keepAlive:true

      }
    },
    {
      path: "/attachedDetail",
      name: "attachedDetail",
      component: attachedDetail,
      meta: {
        title: "附属表详情"
      }
    },
       {
      path: "/attachedEdit",
      name: "attachedEdit",
      component: attachedEdit,
      meta: {
        title: "附属表详情"
      }
    },

    {
      path: "/fileMange",
      name: "fileMange",
      component: fileMange,
      meta: {
        title: "附件管理"
      }
    },
    {
      path: "/PaymentOrder",
      name: "PaymentOrder",
      component: PaymentOrder,
      meta: {
        title: "采购车辆付款单详情"
      }
    },
       {
      path: "/CarStorge",
      name: "CarStorge",
      component: CarStorge,
      meta: {
        title: "车辆入库单"
      }
    },
     {
      path: "/inventoryManageDetail",
      name: "inventoryManageDetail",
      component: inventoryManageDetail,
      meta: {
        title: "库存详情"
      }
    },
        {
      path: "/PurchaseInvoice",
      name: "PurchaseInvoice",
      component: PurchaseInvoice,
      meta: {
        title: "采购发票详情"
      }
    },
      {
      path: "/PaymentOrderEdit",
      name: "PaymentOrderEdit",
      component: PaymentOrderEdit,
      meta: {
        title: "采购车辆付款单编辑"
      }
    },
         {
      path: "/CarStorgeEdit",
      name: "CarStorgeEdit",
      component: CarStorgeEdit,
      meta: {
        title: "车辆入库单编辑"
      }
    },
     {
      path: "/PurchaseInvoiceEdit",
      name: "PurchaseInvoiceEdit",
      component: PurchaseInvoiceEdit,
      meta: {
        title: "采购发票编辑"
      }
    },
     {
      path: "/RepairOrder",
      name: "RepairOrder",
      component: RepairOrder,
      meta: {
        title: "整备工单"
      }
    },
       {
      path: "/YscShop",
      name: "YscShop",
      component: YscShop,
      meta: {
        title: "上架易手车商城"
      }
    },
    {
      path: "/RelateContract",
      name: "RelateContract",
      component: RelateContract,
      meta: {
        title: "选择销售合同"
      }
    },
    {
      path: "/customManage",
      name: "customManage",
      component: customManage,
      meta: {
        title: "客户管理",
        keepAlive:true
      }
    },
    {
      path: "/customManageAdd",
      name: "customManageAdd",
      component: customManageAdd,
      meta: {
        title: "新增客户"
      }
    },
    {
      path: "/customManageDetail",
      name: "customManageDetail",
      component: customManageDetail,
      meta: {
        title: "客户详情"
      }
    },
    {
      path: "/customManageFollowAdd",
      name: "customManageFollowAdd",
      component: customManageFollowAdd,
      meta: {
        title: "跟进记录新增"
      }
    },
    {
      path: "/customManageFollowEdit",
      name: "customManageFollowEdit",
      component: customManageFollowEdit,
      meta: {
        title: "跟进记录修改"
      }
    },
    {
      path: "/customManageFollowDetail",
      name: "customManageFollowDetail",
      component: customManageFollowDetail,
      meta: {
        title: "客户跟进详情"
      }
    },




  ]
})

// 全局前置路由守卫  beforeEach
router.beforeEach((to, from, next) => {
  // 页面切换时，滚动到页面顶部
  document.body.scrollTop = 0 // firefox
  document.documentElement.scrollTop = 0 // safari
  window.pageYOffset = 0 // 调用 next()，一定要调用 next 方法，否则钩子就不会被销毁
  // 判断路由对象
  next()
})

router.afterEach((to) => {
  document.title = to.meta.title || '二手车业务系统'
})

export default router
